#' Online MACD
#'
#' @param short_period short rolling window period
#' @param long_period long rolling window period
#' @param signal_period signal rolling window period
#' @param type type of the moving average
#'
#' @return a stateful function
#' @export
#'
new_macd <- function(short_period = 12L, long_period = 26L, signal_period = 9L,
                     type = c("ema", "tma", "wma", "hma", "dema", "tema", "t3ma",
                              "ewma", "zlema", "vwma", "evwma"))
{
  type <- match.arg(type)
  switch(type,
         ema   = mk_online_func_x("macd", short_period, long_period, signal_period),
         tma   = mk_online_func_x("tmacd", short_period, long_period, signal_period),
         wma   = mk_online_func_x("wmacd", short_period, long_period, signal_period),
         hma   = mk_online_func_x("hmacd", short_period, long_period, signal_period),
         dema  = mk_online_func_x("demacd", short_period, long_period, signal_period),
         tema  = mk_online_func_x("temacd", short_period, long_period, signal_period),
         t3ma  = mk_online_func_x("t3macd", short_period, long_period, signal_period),
         ewma  = mk_online_func_x("ewmacd", short_period, long_period, signal_period),
         zlema = mk_online_func_x("zlemacd", short_period, long_period, signal_period),
         vwma  = mk_online_func_xw("vwmacd", short_period, long_period, signal_period),
         evwma = mk_online_func_xw("evwmacd", short_period, long_period, signal_period))
}
